import {
    CENTER_LIST_GET_REQUEST,
    CENTER_LIST_GET_SUCCESS,
    CENTER_LIST_GET_FAILURE,

    CENTER_DETAIL_GET_REQUEST,
    CENTER_DETAIL_GET_SUCCESS,
    CENTER_DETAIL_GET_FAILURE,

    SET_LIST_LOADING_STATUS
} from '../mutation-types';

import Vue from 'vue';

const state = {
    centers: [],
    center: {}
}
const mutations = {
    /*===============centerList mutation start====================*/
    /**
     * mutation of fetch center list 
     * @param state {Object}
     * @param centerType {String} centertype
     * @param pageIndex {Number} pageIndex
     */
    [CENTER_LIST_GET_SUCCESS](state, centers, pageIndex) {
        //mutation:
        //在Action中 获取数据后  dispatch[CENTER_LIST_GET_SUCCESS]
        //在mutation中进行state的更新
        //在getter中获读取state 
        //即: 读取,更新,使用 分离到 (actions,mutation,getters)
        // state.dispatch(SET_LIST_LOADING_STATUS, false);
        state.centers = centers;
    },
    [CENTER_LIST_GET_REQUEST](state) {
        // state.dispatch(SET_LIST_LOADING_STATUS, true);
    },
    [CENTER_LIST_GET_FAILURE](state) {
        // state.dispatch(SET_LIST_LOADING_STATUS, true);
    },
    /*===============centerList mutation end====================*/



    /*===============centerDetail mutation start================*/
    [CENTER_DETAIL_GET_SUCCESS](state, center, centerId) {
        state.center = center;
    },
    [CENTER_DETAIL_GET_REQUEST](state) {

    },
    [CENTER_DETAIL_GET_FAILURE](state) {

    },
    /*===============centerDetail mutation end==================*/
}
export default {
    state,
    mutations
}
